package business_logic.view;

import java.awt.Color;
import fiuba.algo3.titiritero.modelo.SuperficieDeDibujo;

public class FadeOutText extends TextView
{

    private int m_framesLenght;
    private int m_currentFramesCount;
    
    public FadeOutText( String text, int framesLenght )
    {
        super(text);
        m_currentFramesCount = 0;
        m_framesLenght = framesLenght;
        this.setColor(Color.blue);
    }

    private boolean allFramesDraw()
    {
        return m_currentFramesCount >= m_framesLenght;
    }
    
    @Override
    public void dibujar(SuperficieDeDibujo graphicSurface)
    {
        
        if ( !this.allFramesDraw() )
        {
            // a composite with transparency.
            float transparency = 1-((float)m_currentFramesCount)/((float)m_framesLenght);
            this.setTransparency(transparency);
            
            super.dibujar(graphicSurface);
            m_currentFramesCount++;
        }
    }

    @Override
    public boolean isDone()
    {
        return this.allFramesDraw();
    }
    
    
}
